﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;

namespace ERP.ERPSystem.DataAnalysis
{
    /// <summary>
    /// 物料入库对比图
    /// </summary>
    public interface IInboundCmparisonServices:IApplicationService
    {
        /// <summary>
        /// 获取入库出库趋势数据
        /// </summary>
        /// <param name="startDate">开始日期</param>
        /// <param name="endDate">结束日期</param>
        /// <returns></returns>
        Task<List<InboundOutboundTrendDto>> GetInboundOutboundTrendAsync(DateTime? startDate = null, DateTime? endDate = null);
        
        /// <summary>
        /// 获取入库出库汇总数据
        /// </summary>
        /// <param name="startDate">开始日期</param>
        /// <param name="endDate">结束日期</param>
        /// <returns></returns>
        Task<InboundOutboundSummaryDto> GetInboundOutboundSummaryAsync(DateTime? startDate = null, DateTime? endDate = null);
        
        /// <summary>
        /// 获取详细的入库出库统计数据
        /// </summary>
        /// <param name="startDate">开始日期</param>
        /// <param name="endDate">结束日期</param>
        /// <returns></returns>
        Task<List<InboundOutboundDetailDto>> GetInboundOutboundDetailAsync(DateTime? startDate = null, DateTime? endDate = null);

        /// <summary>
        /// 获取库存柱状图数据
        /// </summary>
        /// <returns></returns>
        Task<List<InventoryBarChartDto>> GetInventoryBarDataAsync();

        /// <summary>
        /// 获取库存趋势折线图数据
        /// </summary>
        /// <returns></returns>
        Task<List<InventoryTrendChartDto>> GetInventoryTrendDataAsync();
    }
    
    /// <summary>
    /// 入库出库趋势数据
    /// </summary>
    public class InboundOutboundTrendDto
    {
        /// <summary>
        /// 日期
        /// </summary>
        public string Date { get; set; }
        
        /// <summary>
        /// 入库数量
        /// </summary>
        public decimal InboundQuantity { get; set; }
        
        /// <summary>
        /// 出库数量
        /// </summary>
        public decimal OutboundQuantity { get; set; }
    }
    
    /// <summary>
    /// 入库出库汇总数据
    /// </summary>
    public class InboundOutboundSummaryDto
    {
        /// <summary>
        /// 总入库量
        /// </summary>
        public decimal TotalInbound { get; set; }
        
        /// <summary>
        /// 总出库量
        /// </summary>
        public decimal TotalOutbound { get; set; }
        
        /// <summary>
        /// 净变化量
        /// </summary>
        public decimal NetChange => TotalInbound - TotalOutbound;
        
        /// <summary>
        /// 统计期间
        /// </summary>
        public string Period { get; set; }
    }
    
    /// <summary>
    /// 入库出库详细数据
    /// </summary>
    public class InboundOutboundDetailDto
    {
        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }
        
        /// <summary>
        /// 入库数量
        /// </summary>
        public decimal InboundQuantity { get; set; }
        
        /// <summary>
        /// 出库数量
        /// </summary>
        public decimal OutboundQuantity { get; set; }
        
        /// <summary>
        /// 库存余量
        /// </summary>
        public decimal StockBalance { get; set; }
    }

    /// <summary>
    /// 库存柱状图数据
    /// </summary>
    public class InventoryBarChartDto
    {
        /// <summary>
        /// 产品物料名称
        /// </summary>
        public string ProductName { get; set; }
        
        /// <summary>
        /// 在库数量
        /// </summary>
        public int GalleryNumber { get; set; }
    }

    /// <summary>
    /// 库存趋势折线图数据
    /// </summary>
    public class InventoryTrendChartDto
    {
        /// <summary>
        /// 入库日期
        /// </summary>
        public string StorageDate { get; set; }
        
        /// <summary>
        /// 在库数量
        /// </summary>
        public int GalleryNumber { get; set; }
    }
}
